<template>
  <div id="app">
    <TopNavigation v-if="showNavigationBars" />
    <div class="layout">
      <SideNavigation v-if="showNavigationBars" />
      <div class="main-content">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import TopNavigation from './components/TopNavigation.vue';
import SideNavigation from './components/SideNavigation.vue';
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';

const route = useRoute();
const showNavigationBars = ref(true);

// 监听路由变化
watch(() => route.fullPath, (newName) => {
  if (newName === '/login') {
    showNavigationBars.value = false;
  } else {
    showNavigationBars.value = true;
  }
});

// 初始化时根据当前路由设置 showNavigationBars 的值
if (route.fullPath === '/login') {
  showNavigationBars.value = false;
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}

.layout {
  display: flex;
}

.main-content {
  flex: 1;
  padding: 20px;
}
</style>